package com.kpiJavaTraining.bogdan.module2;

import java.io.IOException;

/**
 * Class initialize testing
 * @author Bogdan Olexandr
 */
public class Initializer {

	private Checker checker;
	private User user;
	
	public Initializer(User user){
		this.user = user;
		checker = new Checker();
	}
	
	/**
	 * method initializes a test 
	 * @return boolean
	 * @throws IOException
	 * @throws ClassNotFoundException
	 * @throws CloneNotSupportedException
	 */
	public TestStack init() throws IOException, ClassNotFoundException, CloneNotSupportedException{
			if(checker.hasUncompleteTest(getUser())){
				return (new Loader().load(getUser()));	
			}
			InitQuestions questions = new InitQuestions();
			return (new TestStack(questions.getQuestions(),getUser()));
	}
	
	public User getUser() {
		return user;
	}	
}